#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
char str[maxn];
LL nxt[maxn][29];
char ans[maxn];
LL tot=0;
bool vis[maxn];
int main(void)
{
  	cin.tie(0);std::ios::sync_with_stdio(false);
    cin>>(str+1);LL n=strlen(str+1);

    for(LL i=n;i>=1;i--){
        for(LL j=1;j<=26;j++){
            if(i==n) nxt[i][j]=n+1;
            else nxt[i][j]=nxt[i+1][j];
        }
        nxt[i][str[i]-'a'+1]=i;
    }
    LL pos=0;
    while(pos<=n){
        bool flag=1;
        for(char k='a';k<='z';k++){
            if(nxt[pos+1][k-'a'+1]<=n){


                ans[++tot]=k;
              ///  cout<<"nxt["<<pos<<"]["<<(k-'a'+1)<<"]="<<nxt[pos][k-'a'+1]<<"\n";

                pos=nxt[pos+1][k-'a'+1];
               // cout<<"pos="<<pos<<"\n";
                vis[pos]=true;

                flag=0;
             ///   if(pos==n) flag=1;
                break;
            }
        }
      ///  cout<<"pos="<<pos<<"\n";
        if(flag==1||pos==n) break;
    }
    for(LL i=n;i>=1;i--){
        if(!vis[i]) ans[++tot]=str[i];
    }
    for(LL i=1;i<=n;i++){
        cout<<ans[i];
    }
return 0;
}
